package com.vehicle.controller.userController;

import com.vehicle.pojo.VO.CustomersVO;
import com.vehicle.result.PageResult;
import com.vehicle.result.Result;
import com.vehicle.service.SelfMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/selfMessage")
@RestController
@Slf4j
public class selfMessageController {

    @Autowired
    private SelfMessageService selfMessageService;
    /**
     * 个人中心->根据ID查询基本信息
     * @param id 路径参数
     * @return
     */
    @GetMapping("/{id}")
    public Result<CustomersVO> selfMessage(@PathVariable Long id){
        CustomersVO customersVO = selfMessageService.selfMessage(id);
        return Result.success(customersVO);
    }

    /**
     * 根据ID查询历史订单
     * @param id
     * @return
     */
    @GetMapping("/orderHistory")
    public Result<PageResult> orderHistory(Long id){
        log.info("根据ID查询历史订单");
        PageResult pageResult = selfMessageService.orderHistory(id);
        return Result.success(pageResult);
    }
}
